<template>
	<view class="page">
		<!-- 头部 -->
		<u-navbar title="评价" title-color="#000" :border-bottom="false" :title-bold="true">
		</u-navbar>
		<view style="line-height:60rpx;color:#999;margin:0 40rpx;">评价施工师傅</view>
		<view style="background-color:#fff;padding:40rpx;">
			<view style="background-color:#f8f9fb;padding:40rpx 20rpx;">
				<text>你会给TA打几分呢？</text>
				<view style="margin-top:60rpx;text-align:center;">
					<u-rate :gutter="30" :count="5" v-model="form.score" size="60"></u-rate>
				</view>
			</view>
			<view style="height:40rpx;"></view>
			<u-input v-model="form.scoringContent" type="textarea" :height="200" :auto-height="true" maxlength="100" />
			<u-line color="#999" margin="20rpx 0"></u-line>
			<u-upload ref="uUpload" width="160" height="160" :action="action" max-count="4" :show-progress="false">
			</u-upload>
		</view>
		<view style="margin:100rpx 40rpx 0rpx 40rpx;">
			<u-button @click="saveInfo()" type="primary">提交</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				action: "https://gjwy.nephil.cn/sys/annex/fastDFSUploadImg",
				form: {
					scoringContent: "",
					score: 0,
					scoringPicture: ""
				},
				orderId: ""
			}
		},
		onLoad(data) {
			this.orderId = data.id
		},
		methods: {
			saveInfo() {
				let files = []
				this.$refs.uUpload.lists.forEach(element => {
					files.push(element.response.filePath)
				})
				let param = {
					id: this.orderId,
					scoringContent: this.form.scoringContent,
					score: this.form.score,
					scoringPicture: files.join(),
					taskState: 6
				}
				this.$u.api.productUpdate(param).then(res => {
					if (res.code == 200) {
						uni.navigateBack({
							delta: 1
						});
					}
				})
			}
		}
	}
</script>

<style scoped>
	.page {
		min-height: 100%;
		background-color: #f8f9fb;
		font-size: 26rpx;
		color: #222;
	}
</style>
